<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="chrome=1;IE=edge">
    <meta name="viewport" content="user-scalable=no">
    <link rel="stylesheet" href="../../../railView/css/railbox.css" type="text/css" />
    <script type="text/javascript" src="../../../railView/js/railbox-2.0.0.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/UUID.js"></script>

</head>
<body>
    <div id="left" style="width: 50%; height: 100%; position: relative; float: left;background-color: rgb(51, 51, 51);"></div>
    <div id="right" style="width: 50%; height: 100%; position: relative; float: left;"></div>
    <script id="viewerStartup">
        var sheetViewer, modelViewer;
        window.onload = function () {
          // 初始化图纸
          var proleft = new CarsView("left", 'csr', planModelId, callbackleft, {
            isShowAxis: false,
            isShowToolbar	: false,
            isShowCube: false,
            modelServiceUrl: "http://183.56.197.146:11182",
          });
          proleft.then(function (value) {
            sheetViewer = value;
            sheetViewer.initLinkageSheet()
            sheetViewer.setMouseMapping({ left: "pan", middle: "zoom", right: "orbit" });
          });
          // 初始化模型
          var proRight = new CarsView("right", 'csr', exampleModelId, callbackRight,{
            modelServiceUrl: "http://183.56.197.146:11182",
          });
          proRight.then(function (value) {
            modelViewer = value;
            modelViewer.initLinkageModel(modelViewer.getModelRootNode())
          });
        };
        // 图纸回调函数
        function callbackleft(nodeNames, nodeIds, position, center, normal) {
        modelViewer.unSetAllSolidsHighlight()
        sheetViewer.getModelIdFromSheetId(nodeIds[0], modelViewer).then(res => {
          console.log(res)
          if (res.length) {
            modelViewer.setSolidsHighlighted(res, true)
            modelViewer.zoomFitActor(res, 500)
          }
          if(res.length == 0) {
            alert('无联动3d构件')
          }
        })
      }
        // 模型回调函数
        function callbackRight(nodeNames, nodeIds, position, center, normal) {
          sheetViewer.unSetAllSolidsHighlight()
          modelViewer.getSheetIdFromModelId(nodeIds[0], sheetViewer).then(res => {
            if (res.length) {
              sheetViewer.setSolidsHighlighted(res, true)
              sheetViewer.zoomFitActor(res, 500)
            }
            if(res.length == 0) {
              alert('无联动3d图层')
            }
          })
        }
      </script>
</body>
</html>
